import 'package:flutter/material.dart';

class ClassifyDesc extends StatelessWidget {
  final String name;
  final String? desc;

  ClassifyDesc(this.name, {this.desc});

  _createNotDesc(String name) {
    return Row(
      children: [
        Text(
          name,
          style: TextStyle(
            fontSize: 12,
            color: Color.fromRGBO(56, 56, 56, 1),
            fontWeight: FontWeight.bold,
          ),
        ),
        Expanded(
          child: Container(
            margin: EdgeInsets.only(left: 10),
            height: 1,
            color: Color.fromRGBO(242, 242, 242, 1),
          ),
        ),
      ],
    );
  }

  _create(String name, String? desc) {
    return Column(
      children: [
        Row(
          children: [
            Expanded(
              child: Text(
                name,
                style: TextStyle(
                  fontSize: 12,
                  color: Color.fromRGBO(56, 56, 56, 1),
                  fontWeight: FontWeight.bold,
                ),
              ),
            ),
          ],
        ),
        Row(
          children: [
            Text(
              desc!,
              style: TextStyle(
                  fontSize: 10, color: Color.fromRGBO(166, 166, 166, 1)),
            ),
            Expanded(
              child: Container(
                margin: EdgeInsets.only(left: 10),
                height: 1,
                color: Color.fromRGBO(242, 242, 242, 1),
              ),
            ),
          ],
        ),
      ],
    );
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 10, bottom: 10),
      child: desc == null ? _createNotDesc(name) : _create(name, desc),
    );
  }
}
